package base;

import java.io.Serializable;

public class Contact implements Cloneable,Serializable{
	 private static final long serialVersionUID = 8933116149996916899L;
	 private int userbelongedto;
     private User targetuser;
     private int targetuserid;
     private String notes;
     private int contactlevel;
     private String altername;
     private boolean allowedtoviewothercontacts;
     
     public Contact(int currentuserid,User targetuser,String notes,int level,String altername,boolean b){
    	 this.userbelongedto=currentuserid;
    	 this.targetuser=targetuser;
    	 this.targetuserid=targetuser.getid();
    	 this.notes=notes;
    	 this.contactlevel=level;
    	 this.altername=altername;
    	 this.allowedtoviewothercontacts=b;
     }
     public Contact(int currentuserid,int targetuserid,String notes,int level,String altername,boolean b){
    	 this.userbelongedto=currentuserid;
    	 this.targetuserid=targetuserid;
    	 this.notes=notes;
    	 this.contactlevel=level;
    	 this.altername=altername;
    	 this.allowedtoviewothercontacts=b;
     }
     public Contact(int currentuserid,User targetuser){
    	 this(currentuserid,targetuser,"",1,"",false);
     }
     public String getnotes(){return this.notes;}
     public void setnote(String s){this.notes=s;}
     public int getlevel(){return this.contactlevel;}
     public String getaltername(){return this.altername;}
     public void setaltername(String s){this.altername=s;}
     public int getowner(){
    	 return userbelongedto;
     }
     public User gettargetuser(){
    	 return this.targetuser;
     }
     public void settargetuser(User u){
    	 this.targetuser=u;
    	 this.targetuserid=u.getid();
     }
     public int gettargetid(){
    	 return this.targetuserid;
     }
     public String toString(){
    	 if((altername==null)||(altername.equals(""))){
    		 return targetuser.getrealname();
    	 }else{
    		 return targetuser.getrealname()+"("+altername+")";
    	 }
     }
     public boolean getpermissionforcontact(){
    	 return this.allowedtoviewothercontacts;
     }
     
     public void setlevel(int level){
    	 this.contactlevel=level;
     }
     public Contact clone(){
    	 return new Contact(this.userbelongedto,this.targetuser.clone(),this.notes,this.contactlevel,this.altername,this.allowedtoviewothercontacts);
     }
}
